package org.summer.netty;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;

public class FileChannelTest {
    public static void main(String[] args) {
        try (
                FileChannel from = new FileInputStream("from").getChannel();
                FileChannel target = new FileOutputStream("goal").getChannel()
        ) {
            long size = from.size();
            for (long left = size; left > 0;) {
                left -= from.transferTo(size - left, left, target);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
